import java.io.*;

public class ListFiles {
	public static String Scan(File args) {
		
		File outputFile = new File("dir.txt");
		/*try {
			outputFile.createNewFile();
		} catch (IOException e) {
			e.printStackTrace();
		}*/
		
		FileWriter out;
		try {
			out = new FileWriter(outputFile);
		
		
		File[] dir = args.listFiles();
		java.util.Arrays.sort(dir);
			for(int i=0; i<dir.length; i++){
				try {
					out.append(dir[i]+"\n");
					if (dir[i].isDirectory()){
						File pony = dir[i];
						System.out.println(Scan(pony));
					}
					
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					
			}out.close();
			
}
			
			catch (IOException e1) {
					e1.printStackTrace();
				}
			return "Success!";
	}
	}
		
/*		File dir = new File("");
		File[] fileList = dir.listFiles();
		
			for(File f : fileList){
				System.out.println(f.getName());
			}
			
	}
*/	
	/*public static void main(String[] args) {
	    final Collection<File> all = new ArrayList<File>();
	    addFilesRecursively(new File("."), all);
	    System.out.println(all);
	}

	private static void addFilesRecursively(File file, Collection<File> all) {
	    final File[] children = file.listFiles();
	    if (children != null) {
	        for (File child : children) {
	            all.add(child);
	            addFilesRecursively(child, all);
	        }
	    }
	}*/

